//
//  pj_memory_configure.h
//  JOlib
//
//  Created by Pang Jun on 2/11/13.
//  Copyright (c) 2013 Pang Jun. All rights reserved.
//

#ifndef JOlib_pj_memory_configure_h
#define JOlib_pj_memory_configure_h

#include "pj_memory_allocate.h"

template<class TYPE>
class MemoryConfigure
{
public:
    static TYPE* allocate(long n)
    {
        return 0 == n? 0 : (TYPE*)MemoryAlloc::allocate(n * sizeof(TYPE));
    }
    static TYPE* allocate(void)
    {
        return (TYPE*) MemoryAlloc::allocate(sizeof(TYPE));
    }
    static void deallocate(TYPE* ptr, long n)
    {
        if(0 != n)
        {
            MemoryAlloc::deallocate(ptr, n * sizeof(TYPE));
        }
    }
    static void deallocate(TYPE* ptr)
    {
        MemoryAlloc::deallocate(ptr, sizeof(TYPE));
    }
};


#endif
